//
//  YDBuySection3Cell.m
//  PeiZiWangBei
//
//  Created by 巨彦新 on 2018/3/2.
//  Copyright © 2018年 LK-IOS. All rights reserved.
//

#import "YDBuySection3Cell.h"

@interface YDBuySection3Cell ()

/**
 股票名称
 */
@property (nonatomic, strong)UILabel *stockName;

/**
 提示图片
 */
@property (nonatomic, strong)UIImageView *questionImage;

/**
 市价买入
 */
@property (nonatomic, strong)UILabel *buyTypeLbl;


/**
 询价
 */
@property (nonatomic, strong)UIButton *xunjiaBtn;

@end

@implementation YDBuySection3Cell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self stockName];
        [self questionImage];
        [self buyTypeLbl];
        [self xunjiaBtn];
        
    }
    return self;
}
- (void)btnDidSElected:(UIButton *)sender
{
    if (self.clickBack) {
        self.clickBack(sender.titleLabel.text);
    }
}

- (void)tapClick:(UITapGestureRecognizer *)tap
{
    if (self.clickBack) {
        self.clickBack(@"问号");
    }
}
- (UILabel *)stockName
{
    if (!_stockName) {
        _stockName = [UILabel new];
        _stockName.text = @"买入方式";
        _stockName.textColor = [UIColor colorWithHexString:blueyGrey];
        _stockName.font = [UIFont systemFontOfSize:font14ScreenWRate *LKScreenW];
        [self.contentView addSubview:_stockName];
        [_stockName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(rate375(16));
            make.top.equalTo(self.contentView).offset(isPhoneX? rateX812(15) :rate750(15));
        }];
        
    }
    return _stockName;
}
-(UIImageView *)questionImage
{
    if (_questionImage == nil) {
        UIImageView *questtionImage = [[UIImageView alloc] init];
        [self.contentView addSubview:questtionImage];
        questtionImage.userInteractionEnabled = YES;
        [questtionImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stockName.mas_right).offset(rate375(6));
            make.centerY.equalTo(self.stockName.mas_centerY);
        }];
        questtionImage.image = [UIImage imageNamed:@"zdqq-zhujie"];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)];
        [questtionImage addGestureRecognizer:tap];
        
        _questionImage = questtionImage;
    }
    return _questionImage;
}

- (UILabel *)buyTypeLbl
{
    if (!_buyTypeLbl) {
        _buyTypeLbl = [UILabel new];
        _buyTypeLbl.text = @"市价买入";
        _buyTypeLbl.textColor = [UIColor colorWithHexString:dark];
        _buyTypeLbl.font = [UIFont systemFontOfSize:font14ScreenWRate *LKScreenW];
        [self.contentView addSubview:_buyTypeLbl];
        [_buyTypeLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.stockName.mas_centerY);
            make.right.equalTo(self.contentView).offset(-rate375(20));
        }];
        
    }
    return _buyTypeLbl;
}

- (UIButton *)xunjiaBtn
{
    if (!_xunjiaBtn) {
        _xunjiaBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _xunjiaBtn.backgroundColor = [UIColor colorWithHexString:Orange];
        [_xunjiaBtn setTitle:@"确定买入" forState:UIControlStateNormal];
        [self.contentView addSubview:_xunjiaBtn];
        _xunjiaBtn.layer.cornerRadius = 4;
        _xunjiaBtn.layer.masksToBounds = YES;
        [_xunjiaBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(rate375(46));
            make.right.equalTo(self.contentView).offset(rate375(-46));
            if (isPhoneX) {
                make.top.equalTo(self.stockName.mas_bottom).offset(rateX812(56));
                make.height.equalTo(@(rateX812(45)));
            }else
            {
                make.top.equalTo(self.stockName.mas_bottom).offset(rate750(56));
                make.height.equalTo(@(rate750(45)));
            }
        }];
        [_xunjiaBtn addTarget:self action:@selector(btnDidSElected:) forControlEvents:UIControlEventTouchUpInside];
        
        
    }
    return _xunjiaBtn;
}
@end
